﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AppPort;
using TI_EntityLib.TiEntityObjects.AttachInfo;
using TI;

namespace Controllers.AdministrationControllerCommands
{
    /// <summary>
    /// Прогрузка документа
    /// </summary>
    public class LoadAttachContent
    {
        public class inLoadAttachContent
        {
            public string DocID { get; set; }
            public int Part { get; set; }
            public List<TDocumentTable> tables { get; set; }
            public override string ToString()
            {
                return Helper.Json<inLoadAttachContent>.NewtonSerializeObject(this);
            }
        }
        public class outLoadAttachContent : DocumentMetaItem
        {
        }


        public static string Run(ServiceCmd cmd)
        {
            inLoadAttachContent inP = Helper.Json<inLoadAttachContent>.NewtonDeserializeObject(cmd.args.ToString());
            outLoadAttachContent result = (outLoadAttachContent)Helper.MongoTools.Instance.GetEntity<outLoadAttachContent>("loadDocumentMeta('" + inP.DocID + "'," + inP.Part + ")");
            string s = Helper.Json<outLoadAttachContent>.NewtonSerializeObject(result);
            return "{success:true," + s + "}";
        }
    }
}
